package seven.test_7_8;

import java.util.Scanner;

public class TestMain3 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }
        int[] dp = new int[n];
        dp[0] = arr[0];
        dp[1] = arr[1];
        for (int i = 2; i < dp.length; i++) {
            dp[i] = Math.min(dp[i - 1],dp[i - 2]) + arr[i];
        }
        System.out.println(Math.min(dp[n - 1],dp[n - 2]));
    }
}
